package com.webfinal.backsystem.controller;

import com.webfinal.backsystem.request.shoppingcart.CartOperationRequest;
import com.webfinal.backsystem.request.shoppingcart.QueryCartRequest;
import com.webfinal.backsystem.response.shoppingcart.CartOperationResponse;
import com.webfinal.backsystem.response.shoppingcart.QueryCartResponse;
import com.webfinal.backsystem.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class CartController {
    @Autowired
    private CartService cartService;

    @RequestMapping(value = "/api/cart/querycart")
    public QueryCartResponse queryCart(@RequestBody QueryCartRequest request) {
        return cartService.queryCart(request);
    }

    @RequestMapping(value = "/api/cart/operate")
    public CartOperationResponse cartOperation(@RequestBody CartOperationRequest request){
        return cartService.cartOperation(request);
    }
}
